<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * 认证类，加入一些权限认证等方法
 * @author Administrator
 *
 */
class Auth{
    var $user = null;
    //专营店常量
    var $roleSellpoint = 1;
    //小区督导端常量
    var $roleSpsarea = 2;
    //专员端常量
    var $roleSpecial = 3;
    //大区总监常量
    var $roleRegion = 4;
    //区域总监常量
    var $roleArea  = 5;
    //总部常量
    var $roleHead = 6;
    //查看角色常量
    var $roleCheck = 7;
    //时间单位模型
    var $timeUnitModel = null;
    /**
     * 构造函数
     * @param array $user
     */
    function Auth($user){
        $this->user = $user;
        //自定义类使用CI资源使用此方法
        $CI =& get_instance();
        $CI->load->model('timeUnitModel');
        $this->timeUnitModel = $CI->timeUnitModel;
    }
    /**
     * 是否有专营店活动营销基金添加预算申请权限
     * @param array $procData
     * @return boolean
     */
    function isCommonBudgetAdd($procData){
        if ($procData['id']){
            return false;
        }
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply'), $this->user['userLimit'])){
            return false;
        }
        return true;
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['commonTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['commonTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有专营店活动营销基金修改预算申请权限
     * @param array $procData
     * @return boolean
     */
    function isCommonBudgetEdit($procData){
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['commonTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['commonTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有查看专营店活动营销基金预算权限;
     * @param array $procData
     * @return boolean
     */
    function isCommonBudgetCheck($procData){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 判断用户是否存在专营店活动营销基金预算审核权限
     * @param array $procData
     * @return boolean
     */
    function isCommonBudgetAudit($procData){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导才有审核权限
        if (!array_intersect(array('spsarea','head'), $this->user['userLimit'])){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['commonTimeSetting']['budgetAuditStart'] || $nowTime > $timeUnitData['commonTimeSetting']['budgetAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 专营店活动营销基金结算申请权限
     * @param array $procData
     * @return boolean
     */
    function isCommonSettleEdit($procData){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['commonTimeSetting']['settleApplyStart'] || $nowTime > $timeUnitData['commonTimeSetting']['settleApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 专营店活动营销基金结算查看权限
     * @param array $procData
     * @return boolean
     */
    function isCommonSettleCheck($procData){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 专营店活动营销基金结算审核权限
     * @param array $procData
     * @return boolean
     */
    function isCommonSettleAudit($procData){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导、总部才有审核权限
        if (!array_intersect(array('spsarea','head'), $this->user['userLimit'])){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['commonTimeSetting']['settleAuditStart'] || $nowTime > $timeUnitData['commonTimeSetting']['settleAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 单店基金-修改金额权限
     * @param array $procData
     * @return boolean
     */
    function isCommonSettleChange($procData){
        return false;
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有总部才有金额修改权限
        if (!array_intersect(array('head'), $this->user['userLimit'])){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['commonTimeSetting']['settleChangeStart'] || $nowTime > $timeUnitData['commonTimeSetting']['settleChangeEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 判断是否有专营店活动营销基金评分权限
     * @param array $procData
     * @return boolean
     */
    function isCommonSettleSubScore($procData){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有总部才有评分权限
        if (!array_intersect(array('head'), $this->user['userLimit'])){
            return false;
        }
        //上级审核过，下级不允许审核
        if ($this->user['userRole'] < $procData['scoreRole']) {
            return false;
        }
        //地区端取消评分时间限制
        if(array_intersect(array('area'), $this->user['userLimit'])){
            return true;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['commonTimeSetting']['settleScoreStart'] || $nowTime > $timeUnitData['commonTimeSetting']['settleScoreEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有区域营销基金添加预算申请权限
     * @param array $procData
     * @return boolean
     */
    function isAreaBudgetAdd($procData){
        if ($procData['id']){
            return false;
        }
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        return true;
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply'), $this->user['userLimit'])){
            return false;
        }
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['areaTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['areaTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有区域营销基金修改预算申请权限
     * @param array $procData
     * @return boolean
     */
    function isAreaBudgetEdit($procData){
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['areaTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['areaTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有查看区域营销基金预算权限;
     * @param array $procData
     * @return boolean
     */
    function isAreaBudgetCheck($procData){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 判断用户是否存在区域营销基金预算审核权限
     * @param array $procData
     * @return boolean
     */
    function isAreaBudgetAudit($procData){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导才有审核权限
        if (!array_intersect(array('spsarea','head'), $this->user['userLimit'])){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['areaTimeSetting']['budgetAuditStart'] || $nowTime > $timeUnitData['areaTimeSetting']['budgetAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 区域营销基金结算申请权限
     * @param array $procData
     * @return boolean
     */
    function isAreaSettleEdit($procData){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['areaTimeSetting']['settleApplyStart'] || $nowTime > $timeUnitData['areaTimeSetting']['settleApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 区域营销基金结算查看权限
     * @param array $procData
     * @return boolean
     */
    function isAreaSettleCheck($procData){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 区域营销基金结算审核权限
     * @param array $procData
     * @return boolean
     */
    function isAreaSettleAudit($procData){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导、总部才有审核权限
        if (!array_intersect(array('spsarea','head'), $this->user['userLimit'])){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['areaTimeSetting']['settleAuditStart'] || $nowTime > $timeUnitData['areaTimeSetting']['settleAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 单店基金-修改金额权限
     * @param array $procData
     * @return boolean
     */
    function isAreaSettleChange($procData){
        return false;
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有总部才有金额修改权限
        if (!array_intersect(array('head'), $this->user['userLimit'])){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['areaTimeSetting']['settleChangeStart'] || $nowTime > $timeUnitData['areaTimeSetting']['settleChangeEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 判断是否有区域营销基金评分权限
     * @param array $procData
     * @return boolean
     */
    function isAreaSettleSubScore($procData){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有总部才有评分权限
        if (!array_intersect(array('head'), $this->user['userLimit'])){
            return false;
        }
        //上级审核过，下级不允许审核
        if ($this->user['userRole'] < $procData['scoreRole']) {
            return false;
        }
        //地区端取消评分时间限制
        if(array_intersect(array('area'), $this->user['userLimit'])){
            return true;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['areaTimeSetting']['settleScoreStart'] || $nowTime > $timeUnitData['areaTimeSetting']['settleScoreEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有车展基金添加预算申请权限
     * @param array $procData
     * @return boolean
     */
    function isCarBudgetAdd($procData){
        if ($procData['id']){
            return false;
        }
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply'), $this->user['userLimit'])){
            return false;
        }
        return true;
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['carTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['carTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有车展基金修改预算申请权限
     * @param array $procData
     * @return boolean
     */
    function isCarBudgetEdit($procData){
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['carTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['carTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有查看车展基金预算权限;
     * @param array $procData
     * @return boolean
     */
    function isCarBudgetCheck($procData){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 判断用户是否存在车展基金预算审核权限
     * @param array $procData
     * @return boolean
     */
    function isCarBudgetAudit($procData){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导才有审核权限
        if (!array_intersect(array('spsarea','head'), $this->user['userLimit'])){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['carTimeSetting']['budgetAuditStart'] || $nowTime > $timeUnitData['carTimeSetting']['budgetAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 车展基金结算申请权限
     * @param array $procData
     * @return boolean
     */
    function isCarSettleEdit($procData){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['carTimeSetting']['settleApplyStart'] || $nowTime > $timeUnitData['carTimeSetting']['settleApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 车展基金结算查看权限
     * @param array $procData
     * @return boolean
     */
    function isCarSettleCheck($procData){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 车展基金结算审核权限
     * @param array $procData
     * @return boolean
     */
    function isCarSettleAudit($procData){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导、总部才有审核权限
        if (!array_intersect(array('spsarea','head'), $this->user['userLimit'])){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['carTimeSetting']['settleAuditStart'] || $nowTime > $timeUnitData['carTimeSetting']['settleAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 单店基金-修改金额权限
     * @param array $procData
     * @return boolean
     */
    function isCarSettleChange($procData){
        return false;
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有总部才有金额修改权限
        if (!array_intersect(array('head'), $this->user['userLimit'])){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['carTimeSetting']['settleChangeStart'] || $nowTime > $timeUnitData['carTimeSetting']['settleChangeEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 判断是否有车展基金评分权限
     * @param array $procData
     * @return boolean
     */
    function isCarSettleSubScore($procData){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有总部才有评分权限
        if (!array_intersect(array('head'), $this->user['userLimit'])){
            return false;
        }
        //上级审核过，下级不允许审核
        if ($this->user['userRole'] < $procData['scoreRole']) {
            return false;
        }
        //地区端取消评分时间限制
        if(array_intersect(array('area'), $this->user['userLimit'])){
            return true;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['carTimeSetting']['settleScoreStart'] || $nowTime > $timeUnitData['carTimeSetting']['settleScoreEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有巡展基金添加预算申请权限
     * @param array $procData
     * @return boolean
     */
    function isXunBudgetAdd($procData){
        if ($procData['id']){
            return false;
        }
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply'), $this->user['userLimit'])){
            return false;
        }
        return true;
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['xunTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['xunTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有巡展基金修改预算申请权限
     * @param array $procData
     * @return boolean
     */
    function isXunBudgetEdit($procData){
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['xunTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['xunTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有查看巡展基金预算权限;
     * @param array $procData
     * @return boolean
     */
    function isXunBudgetCheck($procData){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 判断用户是否存在巡展基金预算审核权限
     * @param array $procData
     * @return boolean
     */
    function isXunBudgetAudit($procData){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导才有审核权限
        if (!array_intersect(array('spsarea','head'), $this->user['userLimit'])){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['xunTimeSetting']['budgetAuditStart'] || $nowTime > $timeUnitData['xunTimeSetting']['budgetAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 巡展基金结算申请权限
     * @param array $procData
     * @return boolean
     */
    function isXunSettleEdit($procData){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        return true;
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['xunTimeSetting']['settleApplyStart'] || $nowTime > $timeUnitData['xunTimeSetting']['settleApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 巡展基金结算查看权限
     * @param array $procData
     * @return boolean
     */
    function isXunSettleCheck($procData){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 巡展基金结算审核权限
     * @param array $procData
     * @return boolean
     */
    function isXunSettleAudit($procData){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导、总部才有审核权限
        if (!array_intersect(array('spsarea','head'), $this->user['userLimit'])){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['xunTimeSetting']['settleAuditStart'] || $nowTime > $timeUnitData['xunTimeSetting']['settleAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 单店基金-修改金额权限
     * @param array $procData
     * @return boolean
     */
    function isXunSettleChange($procData){
        return false;
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有总部才有金额修改权限
        if (!array_intersect(array('head'), $this->user['userLimit'])){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['xunTimeSetting']['settleChangeStart'] || $nowTime > $timeUnitData['xunTimeSetting']['settleChangeEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 判断是否有巡展基金评分权限
     * @param array $procData
     * @return boolean
     */
    function isXunSettleSubScore($procData){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有总部才有评分权限
        if (!array_intersect(array('head'), $this->user['userLimit'])){
            return false;
        }
        //上级审核过，下级不允许审核
        if ($this->user['userRole'] < $procData['scoreRole']) {
            return false;
        }
        //地区端取消评分时间限制
        if(array_intersect(array('area'), $this->user['userLimit'])){
            return true;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['xunTimeSetting']['settleScoreStart'] || $nowTime > $timeUnitData['xunTimeSetting']['settleScoreEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有专项基金添加预算申请权限
     * @param array $procData
     * @return boolean
     */
    function isSpecialBudgetAdd($procData){
        if ($procData['id']){
            return false;
        }
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply'), $this->user['userLimit'])){
            return false;
        }
        return true;
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['specialTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['specialTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有专项基金修改预算申请权限
     * @param array $procData
     * @return boolean
     */
    function isSpecialBudgetEdit($procData){
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['specialTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['specialTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有查看专项基金预算权限;
     * @param array $procData
     * @return boolean
     */
    function isSpecialBudgetCheck($procData){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 判断用户是否存在专项基金预算审核权限
     * @param array $procData
     * @return boolean
     */
    function isSpecialBudgetAudit($procData){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导才有审核权限
        if (!array_intersect(array('spsarea','head'), $this->user['userLimit'])){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['specialTimeSetting']['budgetAuditStart'] || $nowTime > $timeUnitData['specialTimeSetting']['budgetAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 专项基金结算申请权限
     * @param array $procData
     * @return boolean
     */
    function isSpecialSettleEdit($procData){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['specialTimeSetting']['settleApplyStart'] || $nowTime > $timeUnitData['specialTimeSetting']['settleApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 专项基金结算查看权限
     * @param array $procData
     * @return boolean
     */
    function isSpecialSettleCheck($procData){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 专项基金结算审核权限
     * @param array $procData
     * @return boolean
     */
    function isSpecialSettleAudit($procData){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导、总部才有审核权限
        if (!array_intersect(array('spsarea','head'), $this->user['userLimit'])){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['specialTimeSetting']['settleAuditStart'] || $nowTime > $timeUnitData['specialTimeSetting']['settleAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 单店基金-修改金额权限
     * @param array $procData
     * @return boolean
     */
    function isSpecialSettleChange($procData){
        return false;
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有总部才有金额修改权限
        if (!array_intersect(array('head'), $this->user['userLimit'])){
            return false;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['specialTimeSetting']['settleChangeStart'] || $nowTime > $timeUnitData['specialTimeSetting']['settleChangeEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 判断是否有专项基金评分权限
     * @param array $procData
     * @return boolean
     */
    function isSpecialSettleSubScore($procData){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有总部才有评分权限
        if (!array_intersect(array('head'), $this->user['userLimit'])){
            return false;
        }
        //上级审核过，下级不允许审核
        if ($this->user['userRole'] < $procData['scoreRole']) {
            return false;
        }
        //地区端取消评分时间限制
        if(array_intersect(array('area'), $this->user['userLimit'])){
            return true;
        }
        return true;
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['specialTimeSetting']['settleScoreStart'] || $nowTime > $timeUnitData['specialTimeSetting']['settleScoreEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有批量提交按钮
     * @return boolean
     */
    function isBatchAudit(){
        //只有总部才有评分权限
        if (!array_intersect(array('spsarea','head'), $this->user['userLimit'])){
            return false;
        }
        return true;
    }
    /**
     * 判断是否有导入管理权限
     * @return boolean
     */
    function isImport(){
        if ($this->user['userRole'] != $this->roleHead){
            return false;
        }
        return true;
    }
}